import React, { Component } from "react";
// 一切皆组件
//只要我们使用路由，必须在最外面加上BrowserRouter的组件

// Link是一个做路由跳转的组件，相当于vue的router-link，要有一个to属性
// Route组件用于渲染单个组件的, 需要有path和component属性
// Switch叫做分支匹配,将路由变成排他性路由
import { Link, Route, Switch } from "react-router-dom";

class Home extends Component {
  render() {
    return <div>home页面</div>;
  }
}

class About extends Component {
  render() {
    return <div>about页面</div>;
  }
}

class Mine extends Component {
  render() {
    return <div>mine页面</div>;
  }
}

class App extends Component {
  render() {
    return (
      <>
        <h3>react-router-基础</h3>
        <ul>
          <li>
            <Link to="/">home</Link>
          </li>
          <li>
            <Link to="/about">about</Link>
          </li>
          <li>
            <Link to="/mine">mine</Link>
          </li>
        </ul>

        <hr />

        <Switch>
          {/* vue默认是排他性路由，react路由默认是包容性路由 */}
          {/* exact属性表示精准匹配 */}
          <Route path="/" component={Home} exact></Route>
          <Route path="/about" component={About}></Route>
          <Route path="/mine" component={Mine}></Route>
        </Switch>
      </>
    );
  }
}

export default App;
